<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>echarts</title>
  <style>
    #chart {
      width: 800px;
      height: 400px;
    }
  </style>
</head>

<body>
  <!-- 2. 准备一个具备宽高的DOM容器 -->
  <div id="chart"></div>
  <!-- 1. 引入echarts的js文件 -->
  <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.0/echarts.min.js"></script>

  <script>
    // 3. 获取echarts实例
    const myEcharts = echarts.init(document.getElementById('chart'))
    // 4. 定义图表option
    const option = {
      xAxis: {
        data: [
          '一月',
          '二月',
          '三月',
          '四月',
          '五月',
          '六月',
          '七月',
          '八月',
          '九月',
          '十月',
          '十一月',
          '十二月',
        ]
      },
      yAxis: {},
      dataset: {
        source: [
          ['一月', 50, 150, 'x', 111],
          ['二月', 55, 155, 'y', 222],
          ['三月', 44, 144, 'z', 333],
          ['四月', 65, 65],
          ['五月', 78, 178],
          ['六月', 62, 162],
          ['七月', 50, 150],
          ['八月', 55, 155],
          ['九月', 44, 144],
          ['十月', 65, 65],
          ['十一月', 78, 178],
          ['十二月', 62, 162],
        ]
      },
      series: [ // 数组，可以放置n个图表
        {
          type: 'bar',
          encode: {
            x: 0,
            y: 1
          }
        },
        {
          type: 'line',
          encode: {
            x: 0,
            y: 2
          }
        },
        {
          type: 'pie',
          encode: {
            itemName: 3,
            value: 4
          },
          radius: [0, 30],
          center: ['50%', 40] // 圆心
        }
      ]
    }
    // 5. 生成图表
    myEcharts.setOption(option)
  </script>
</body>

</html>